<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>编辑用户</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" th:href="@{/plugins/layui/css/layui.css}" media="all" />
	<link rel="stylesheet" th:href="@{/plugins/font-awesome/css/font-awesome.min.css}">
</head>
<body>
	<div style="margin: 15px;" id="content">

	</div>
	<script type="text/html" id="tpl">
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			<legend>编辑用户</legend>
		</fieldset>
		<form class="layui-form" enctype="multipart/form-data" class="layui-form">
			<div class="layui-form-item">
				<label class="layui-form-label">用户名</label>
				<div class="layui-input-block">
					<input type="text" value="<%==$data.account%>" name="account" lay-verify="required" autocomplete="off" placeholder="请输入用户名" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">邮箱</label>
				<div class="layui-input-block">
					<input type="text" name="email" value="<%==$data.email%>" lay-verify="required" autocomplete="off" placeholder="请输入姓名" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">手机</label>
				<div class="layui-input-block">
					<input type="text" name="phone" value="<%==$data.phoneNumber%>" lay-verify="required" autocomplete="off" placeholder="请输入姓名" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">密码</label>
				<div class="layui-input-block">
					<input type="password" value="<%==$data.password%>" name="password" lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<input class="layui-btn" type="button" lay-submit="" lay-filter="edit" value="立即提交">
				</div>
			</div>
		</form>
	</script>
	<script type="text/javascript" src="../plugins/layui/layui.js"></script>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript" src="../js/template.js"></script>
	<script type="text/javascript" src="../js/public.js"></script>
	<script>
		var id = getUrlParam("id");

		$.ajax({
			url:"/admin/user/getIdAdmin?aid="+id,
			dataType:'json',
			async:false,
			success:function(res){
				var html  = template("tpl",res.result);
				document.getElementById("content").innerHTML = html;
			}
		});

		layui.use(['form', 'layedit', 'laydate', 'element'], function() {
			var form = layui.form(),
				layer = layui.layer,
				layedit = layui.layedit,
				laydate = layui.laydate;
				var $ = layui.jquery,
				element = layui.element();


			form.verify({

			});

			form.on('submit(edit)', function(data) {
				console.log(data);
				var  url = "/admin/user/upAdminDate?account="+data.field.account+"&password="+data.field.password+"&phone="+data.field.phone+"&email="+data.field.email+"&aid="+id;
				$.ajax({
					url: url,
					type: "post",
					datatype: "json",
					success: function(data) {
						if (data.code == 200) {
						toast("修改成功");
					}else{
						toast("修改失败");
					}
					}
				});
				return false;
			});

		});
	</script>
</body>

</html>
